<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Report generation criteria</title>
</head>
<body>
<h1>Admin page for report management </h1>

<h2>Please enter the report criteria -</h2>
<%--Here the commandName should exactly match the @ModelAttribute("report") in the controller including cases --%>
<form:form method="post" action="add.html" commandName="report"> 
 
    <table>
    <tr>
        <td><form:label path="reportName">Report Name</form:label></td>
        <td><form:input path="reportName"/></td>
    </tr>
    <tr>
        <td><form:label path="reportFormat">Report Format</form:label></td>
        <td><form:input path="reportFormat"/></td>
    </tr>
    <tr>
        <td><form:label path="templateName">Template Name</form:label></td>
        <td><form:input path="templateName"/></td>
    </tr>
    <tr>
        <td><form:label path="language">Language (default English)</form:label></td>
        <td><form:input path="language"/></td>
    </tr>
    <tr>
        <td><form:label path="reportQuery">Report Query</form:label></td>
        <td><form:input path="reportQuery"/></td>
    </tr>
    <tr>
        <td><form:label path="reportLink">Report link</form:label></td>
        <td><form:input path="reportLink"/></td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" value="Generate report"/>
        </td>
    </tr>
</table>  
 
</form:form>

 <h3>Contacts - ${reportList}</h3>

<c:if  test="${!empty reportList}">
<table class="data">
<tr>
    <th>Report Name</th>
    <th>Report Format</th>
    <th>Template Name</th>
    <th>Report Query</th>
    <th>Report Link</th>
    <th>&nbsp;</th>
</tr>
<c:forEach items="${reportList}" var="report">
    <tr>
        <td>${report.reportName}</td>
        <td>${report.reportFormat}</td>
        <td>${report.templateName}</td>
        <td>${report.reportQuery}</td>
        <td>${report.reportLink}</td>
        <td><a href="delete/${report.id}">delete</a></td>
    </tr>
</c:forEach> 
</table>
</c:if>
</body>
</html>